var webName = "/tbpoject";
var webFore = webName + "/foreground";
var loginPath = webFore + "/login.html";//登录
var indexPath = webFore + "/index.html";//首页
var registerPath = webFore + "/register.html";//注册页面
var accManage = webFore + "/zhanghao.html";//我的淘宝
var shopPath = webFore + "/myshoppingcar.html";//购物车
var goodsCollection = webFore + "/collection.html";//收藏宝贝
var storeCollection = webFore + "/storecollection.html";//收藏店铺

//最上面导航栏修改
$(document).ready(function(){
	accountAJAXTools();
});

//账户异步请求
function accountAJAXTools(){
	$("#J_SiteNavHome > .site-nav-menu-hd").html("<a href='" + indexPath + "' target='_top' >淘宝首页</a>");
	$("#J_SiteNavMytaobao > .site-nav-menu-hd").html("<a href='" + accManage + "' target='_top' >我的淘宝</a>");
	$("#J_MiniCart > .site-nav-menu-hd").html("<a href='" + shopPath + "' target='_top' >购物车</a>");
	$("#J_SiteNavFavor > .site-nav-menu-hd").html("<a href='" + shopPath + "' target='_top' >收藏夹</a>");
	$.ajax({
        type : 'post',
        url  : '/tbpoject/customerControler/getCustomerJson',
        contentType : 'application/json; charset = utf-8',
        data : '',
        dataType : 'json',
        success : function(data){
            if(data != null){
            	//登录成功
            	$(".site-nav-user").html('<a href="' + accManage + '" target="_top" class="site-nav-login-info-nick">' + data.name + '</a>');
            	$("#J_SiteNavMytaobao > .site-nav-menu-hd").html("<a href='" + accManage + "' target='_top' >我的淘宝</a>");
            	$("#J_MiniCart > .site-nav-menu-hd").html("<a href='" + shopPath + "' target='_top' >购物车</a>");
            	$("#J_SiteNavFavor > .site-nav-menu-hd").html("<a href='" + shopPath + "' target='_top' >收藏夹</a>");
            }else{
            	//登录失败
            	$(".site-nav-user").html('<a href="/tbpoject/foreground/login.html" target="_top" class="site-nav-login-info-nick">请先登录</a>');
            	$(".site-nav-login-info-nick").text("请先登录")
            	$("#J_SiteNavMytaobao > .site-nav-menu-hd").remove();
            	$("#J_MiniCart > .site-nav-menu-hd").remove();
            	$("#J_SiteNavFavor > .site-nav-menu-hd").remove();

            }
        },
        error : function(){
            alert("请检查网络或联系管理员")
        }
    });
}